import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {HttpClient} from '@angular/common/http';
import {ActivatedRoute, Router} from '@angular/router';
import {VAILDATOR_COMMON} from '../../service/form-validator';
import { registerLocaleData } from '@angular/common';
import zh from '@angular/common/locales/zh';
registerLocaleData(zh);
@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
  validateForm: FormGroup;
  panels = [
    {
      active: true,
      name: 'This is panel header 1',
      disabled: false
    },
    {
      active: false,
      disabled: false,
      name: 'This is panel header 2'
    },
    {
      active: false,
      disabled: true,
      name: 'This is panel header 3'
    }
  ];
  constructor(private fb: FormBuilder,
              private httpClient: HttpClient,
              private router: Router,
  ) {
  }

  ngOnInit() {
    this.validateForm = this.fb.group({
      userName: ['', [Validators.required, Validators.maxLength(VAILDATOR_COMMON.TITLE_LEG.MAX)]],
      password: ['', Validators.required],
      remember: [true]
    });
  }

  getFormControl(name) {
    return this.validateForm.controls[name];
  }
  setMAxDate(currt: Date): boolean {
    return currt && currt.getTime() > Date.now();
  }
}
